package com.duowei.diandan.db.entry;

import android.arch.persistence.room.Entity;
import android.arch.persistence.room.Ignore;
import android.arch.persistence.room.PrimaryKey;

import com.duowei.diandan.db.MenuItem;
import com.duowei.diandan.db.MenuItemType;

import org.joda.time.LocalDateTime;

/**
 * 套餐名称
 */
@SuppressWarnings("ALL")
@Entity
public class Tcmc implements MenuItem {
    @PrimaryKey(autoGenerate = true)
    private long id;

    /** 套餐编号 */
    private String xmbh;
    /** 套餐名称 */
    private String xmmc;
    /** 套餐类别 */
    private String lbmc;
    /** 排序号 */
    private Float xl;
    /** 单品内部编号 */
    private String tm;
    private String by1;
    private String by2;
    private String by3;
    /** 有效期结束时间-日期 */
    private LocalDateTime by4;
    private Float by5;
    /** 拼音 */
    private String py;
    /** 周一 */
    private String z1;
    private String z2;
    private String z3;
    private String z4;
    private String z5;
    private String z6;
    /** 周日 */
    private String z7;
    /** 有效期开始时间-时间 */
    private LocalDateTime kssj;
    /** 有效期结束时间-时间 */
    private LocalDateTime jssj;
    /** 有效期开始时间-日期 */
    private LocalDateTime ksrq;
    private String sfwx;
    private String by6;

    // -------
    // 套餐类别
    @Ignore
    private String tcCateName;

    public Tcmc() {
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getXmbh() {
        return xmbh;
    }

    public void setXmbh(String xmbh) {
        this.xmbh = xmbh;
    }

    public String getXmmc() {
        return xmmc;
    }

    public void setXmmc(String xmmc) {
        this.xmmc = xmmc;
    }

    public String getLbmc() {
        return lbmc;
    }

    public void setLbmc(String lbmc) {
        this.lbmc = lbmc;
    }

    public Float getXl() {
        return xl;
    }

    public void setXl(Float xl) {
        this.xl = xl;
    }

    public String getTm() {
        return tm;
    }

    public void setTm(String tm) {
        this.tm = tm;
    }

    public String getBy1() {
        return by1;
    }

    public void setBy1(String by1) {
        this.by1 = by1;
    }

    public String getBy2() {
        return by2;
    }

    public void setBy2(String by2) {
        this.by2 = by2;
    }

    public String getBy3() {
        return by3;
    }

    public void setBy3(String by3) {
        this.by3 = by3;
    }

    public LocalDateTime getBy4() {
        return by4;
    }

    public void setBy4(LocalDateTime by4) {
        this.by4 = by4;
    }

    public Float getBy5() {
        return by5;
    }

    public void setBy5(Float by5) {
        this.by5 = by5;
    }

    public String getPy() {
        return py;
    }

    public void setPy(String py) {
        this.py = py;
    }

    public String getZ1() {
        return z1;
    }

    public void setZ1(String z1) {
        this.z1 = z1;
    }

    public String getZ2() {
        return z2;
    }

    public void setZ2(String z2) {
        this.z2 = z2;
    }

    public String getZ3() {
        return z3;
    }

    public void setZ3(String z3) {
        this.z3 = z3;
    }

    public String getZ4() {
        return z4;
    }

    public void setZ4(String z4) {
        this.z4 = z4;
    }

    public String getZ5() {
        return z5;
    }

    public void setZ5(String z5) {
        this.z5 = z5;
    }

    public String getZ6() {
        return z6;
    }

    public void setZ6(String z6) {
        this.z6 = z6;
    }

    public String getZ7() {
        return z7;
    }

    public void setZ7(String z7) {
        this.z7 = z7;
    }

    public LocalDateTime getKssj() {
        return kssj;
    }

    public void setKssj(LocalDateTime kssj) {
        this.kssj = kssj;
    }

    public LocalDateTime getJssj() {
        return jssj;
    }

    public void setJssj(LocalDateTime jssj) {
        this.jssj = jssj;
    }

    public LocalDateTime getKsrq() {
        return ksrq;
    }

    public void setKsrq(LocalDateTime ksrq) {
        this.ksrq = ksrq;
    }

    public String getSfwx() {
        return sfwx;
    }

    public void setSfwx(String sfwx) {
        this.sfwx = sfwx;
    }

    public String getBy6() {
        return by6;
    }

    public void setBy6(String by6) {
        this.by6 = by6;
    }

    public String getTcCateName() {
        return tcCateName;
    }

    public void setTcCateName(String tcCateName) {
        this.tcCateName = tcCateName;
    }

    @Override
    public String getImageNo() {
        return this.xmbh;
    }

    @Override
    public String getName() {
        return this.xmmc;
    }

    @Override
    public String getPriceDesc() {
        return null;
    }

    @Override
    public MenuItemType getType() {
        return MenuItemType.MEAL;
    }

    public static String querySql() {
//        if (Settings.ONLY_SHOW_BY21) {
//            return sql21();
//        } else {
//            return sql0();
//        }

        return "SELECT xmbh, xmmc, lbmc, xl, tm, by1, by2, by3, by4, by5, py, z1, z2, z3, z4, " +
                "z5, z6, z7, kssj, jssj, ksrq, sfwx, by6 FROM tcmc|";
    }

    private static String sql0() {
        return "SELECT xmbh, xmmc, lbmc, xl, tm, by1, by2, by3, by4, by5, py, z1, z2, z3, z4, " +
                "z5, z6, z7, kssj, jssj, ksrq, sfwx, by6 FROM tcmc " +
                "WHERE xmbh in (select tcsd.xmbh from TCSD, JYXMSZ where TCSD.XMBH1 = JYXMSZ.xmbh and isnull(JYXMSZ.sfqx, 0) != '1')|";
    }

    private static String sql21() {
        return "SELECT xmbh, xmmc, lbmc, xl, tm, by1, by2, by3, by4, by5, py, z1, z2, z3, z4, " +
                "z5, z6, z7, kssj, jssj, ksrq, sfwx, by6 FROM tcmc " +
                "WHERE xmbh in (select tcsd.xmbh from TCSD, JYXMSZ where TCSD.XMBH1 = JYXMSZ.xmbh and isnull(JYXMSZ.by21, 0) = '1' and isnull(JYXMSZ.sfqx, 0) != '1')|";
    }
}
